﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace HomeAutomation
{
    class StateImpl : State
    {
        private Flow flow;
        private Dictionary<FlowEvent, State> transitions =  new Dictionary<FlowEvent, State>();
        public List<Action> actions = new List<Action>();


        public StateImpl(Flow flow)
        {
            this.flow = flow;
            flow.AddState(this);
        }

        public StateImpl(Flow flow, params Action[] actions) : this(flow)
        {
                this.actions.AddRange(actions);
        }

        public void addTransition(FlowEvent fe, State s)
        {
            transitions.Add(fe, s);
        }

        public void process(FlowEvent fe)
        {
            foreach (KeyValuePair<FlowEvent, State> entry in transitions)
            {
                if (entry.Key.Equals(fe))
                {
                    //we are here
                }
            }
        }

        public void fireActions()
        {
            foreach (Action action in actions)
            {
                action.fire();
            }
        }
    }
}
